package com.naiterui.ehp.bs.recommend.controller.assist;


import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.recommend.exception.ExceptionCodes;
import com.naiterui.ehp.bs.recommend.service.IAssistService;
import com.naiterui.ehp.bs.recommend.swagger.Tags;
import com.naiterui.ehp.bs.recommend.vo.assist.DrugRemindParamVO;
import com.naiterui.ehp.bs.recommend.vo.assist.DrugRemindVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用药提醒相关
 *
 * @author gaoliangliang
 * @date 2019-06-19 14:35
 * @since 1.0.0
 */
@Slf4j
@Api(tags = {SwaggerTag.PATIENT + SwaggerTag.MEDICINE_REMIND})
@RequestMapping("recommend/drugremind")
@RestController
public class DrugRemindController {

    private final IAssistService assistService;

    public DrugRemindController(IAssistService assistService) {
        this.assistService = assistService;
    }


    @GetMapping
    @ApiOperation(tags = { Tags.RECOMMEND_ASSIST, Tags.WX }, value = "用药提醒设置信息", notes = "用药提醒设置信息", httpMethod = "GET")
    @ApiImplicitParams({ @ApiImplicitParam(name = "recomId", value = "处方ID", required = true, dataType = "long", paramType = "query") })
    public ResponseVO<DrugRemindVO> drugRemind(Long recomId) {
        log.info("用药提醒设置信息，recomId {}", recomId);
        DrugRemindVO drugRemindVO = assistService.drugRemind(recomId);
        return PublicService.returnResponseVO(drugRemindVO);
    }


    @PostMapping
    @ApiOperation(tags = { Tags.RECOMMEND_ASSIST, Tags.WX }, value = "保存用药提醒设置", notes = "保存用药提醒设置", httpMethod = "POST")
    public ResponseVO<Void> saveDrugRemind(@RequestBody DrugRemindParamVO drugRemindParamVO) throws BusinessException {
        log.info("保存用药提醒，参数信息: {}", drugRemindParamVO.toString());
        assistService.saveDrugRemind(drugRemindParamVO);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }
}

